using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace caseDrawer
{
	public class TXTWriter : IWriter
	{
		string testCaseFolder;
		public string TestCaseFolder{
			set{ testCaseFolder = value;}			
		}
		
		Senario senario;
		public Senario Senario{
			set{senario = value;}			
		}
		
		public TXTWriter()
		{
		}

		public void write(string title,IList<string> results){
            try
            {   
            	string testCaseFile = this.testCaseFolder+"senario_"+ this.senario.Id+"_" + getFormatedTime()+".txt";
            	         			
        	  	StreamWriter sw = new StreamWriter(testCaseFile,false);
                
        	  	sw.WriteLine(title);
                foreach (string result in results)
                {
                    sw.WriteLine(result);
                }
                
                sw.Close();
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message);
            }
		}
		
		string getFormatedTime(){
			string t = DateTime.Now.ToString().Replace("/","").Replace(":","").Replace(" ","").Replace("PM","");
			//Random t = new Random(1000);
			
			return t;
			
		}
	}
}
